<?php

class Admin_CfgGalleryController extends Nippy_Controller_Config_Abstract {
	public function init(){
		$this->_editorName = "Nippy.Components.NodeEditors.Gallery";
	}
	
	public function putAction() {
		$request = $this->getRequest();
    	parse_str($request->getRawBody(),$params);
    	$id = (int)$params['id'];
    	if ($id>0)
    	{
    		$form = new Admin_Form_Gallery();
    		if ($form->isValid($params))
    		{
	    		$m = new Admin_Model_TreeNodeMapper();
	    		$params['InMenu'] = isset($params['InMenu'])? 1 : 0;
	    		
	    		$val = $form->getValidValues($params);
	    		$node = new Admin_Model_Page($val);
	    		$node->setId($id);
	    		$node->pack();
	    		$val['XML'] = '';
	    		$val['HTML'] = '';
	    		$m->save($node,array_intersect_key(Admin_Model_TreeNode::getFields(), $val));
	    		$result = array('success'=>true, 'msg'=>'Страница сохранена');
    		}
    		else
    			$result = array('success'=>false, 'msg'=>'Данные некорректны');
    	}
    	else
    		$result = array('success'=>false, 'msg'=>'Не установлен id');
	    $this->_helper->json($result);
	}
}

?>